package concurrency;

class Chopstick {
    private boolean mTakenState = false;

    public synchronized void take() throws InterruptedException {
        while (mTakenState) {
            wait();
        }
        mTakenState = true;
    }

    public synchronized void drop() {
        mTakenState = false;
        notifyAll();
    }
}
